#!/usr/bin/env python
"""Bot para clan de CoR."""

import logging
from telegram.ext import (Updater, CommandHandler,
                          MessageHandler, Filters)
import countdown

TOKEN = '534307579:AAE1rLkejF0RDb29xflIbLyXuMhiaa0aSwQ'

logging.basicConfig(
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    level=logging.INFO)
LOG = logging.getLogger(__name__)


def start(bot, update):
    msg = ('Saludos {}, soy el guardián del reino, será un '
           'placer servirle y responder vuestras dudas').format(
               update.message.from_user.first_name)
    bot.send_message(chat_id=update.message.chat_id, text=msg)


def help_c(bot, update):
    print(bot.send_message)
    update.message.reply_text('¡Ayuda!')


def err(bot, update, error):
    LOG.warning('Update "%s" cause error "%s"', update, error)


def echo(bot, update):
    bot.send_message(chat_id=update.message.chat_id,
                     text=update.message.text)


def respawn(bot, update):
    eve = 'Evendim: ' + countdown.countdown(1, 20, 20)
    tku = 'Thorkul: ' + countdown.countdown(1, 4, 28)
    dar = 'Daen Rha: ' + countdown.countdown(2, 20, 30)
    msg = '{}\n {}\n {}\n'.format(eve, tku, dar)
    bot.send_message(chat_id=update.message.chat_id, text=msg)


def main():
    updater = Updater(TOKEN)
    dispatcher = updater.dispatcher
    dispatcher.add_handler(CommandHandler('start', start))
    dispatcher.add_handler(CommandHandler('help', help_c))
    dispatcher.add_handler(CommandHandler('epicos', respawn))
    dispatcher.add_error_handler(err)
    dispatcher.add_handler(MessageHandler(Filters.text, echo))
    updater.start_polling()
    updater.idle()


if __name__ == '__main__':
    main()
